package org.fuys.etp.repo.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;

/**
 * 弹性线程池策略配置
 * @TableName etp_strategy
 */
@TableName(value ="etp_strategy")
@Data
public class EtpStrategy implements Serializable {
    /**
     * 策略ID 主键自增
     */
    @TableId(type = IdType.AUTO)
    private Integer strategyId;

    /**
     * 策略名称
     */
    private String strategyName;

    /**
     * 策略描述
     */
    private String strategyDesc;

    /**
     * 策略类型
     */
    private Object strategyType;

    /**
     * 负载配置链 多个配置通过,分割
     */
    private String loadChain;

    /**
     * 起始负载配置等级
     */
    private Object startLoadLevel;

    /**
     * 用于报警处理的Bean名称
     */
    private String alertType;

    /**
     * 报警等级 当切换的配置为此等级时会触发报警
     */
    private Object alertLevel;

    /**
     * 报警处理人
     */
    private String alertTo;

    /**
     * 用于配置更新检查时的Bean名称 利用,分开 从etp_component中获取
     */
    private String checkerChain;

    /**
     * 用于配置数据监控时的Bean名称 利用,分开 从etp_component中获取
     */
    private String metricsChain;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        EtpStrategy other = (EtpStrategy) that;
        return (this.getStrategyId() == null ? other.getStrategyId() == null : this.getStrategyId().equals(other.getStrategyId()))
            && (this.getStrategyName() == null ? other.getStrategyName() == null : this.getStrategyName().equals(other.getStrategyName()))
            && (this.getStrategyDesc() == null ? other.getStrategyDesc() == null : this.getStrategyDesc().equals(other.getStrategyDesc()))
            && (this.getStrategyType() == null ? other.getStrategyType() == null : this.getStrategyType().equals(other.getStrategyType()))
            && (this.getLoadChain() == null ? other.getLoadChain() == null : this.getLoadChain().equals(other.getLoadChain()))
            && (this.getAlertType() == null ? other.getAlertType() == null : this.getAlertType().equals(other.getAlertType()))
            && (this.getCheckerChain() == null ? other.getCheckerChain() == null : this.getCheckerChain().equals(other.getCheckerChain()))
            && (this.getMetricsChain() == null ? other.getMetricsChain() == null : this.getMetricsChain().equals(other.getMetricsChain()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getStrategyId() == null) ? 0 : getStrategyId().hashCode());
        result = prime * result + ((getStrategyName() == null) ? 0 : getStrategyName().hashCode());
        result = prime * result + ((getStrategyDesc() == null) ? 0 : getStrategyDesc().hashCode());
        result = prime * result + ((getStrategyType() == null) ? 0 : getStrategyType().hashCode());
        result = prime * result + ((getLoadChain() == null) ? 0 : getLoadChain().hashCode());
        result = prime * result + ((getAlertType() == null) ? 0 : getAlertType().hashCode());
        result = prime * result + ((getCheckerChain() == null) ? 0 : getCheckerChain().hashCode());
        result = prime * result + ((getMetricsChain() == null) ? 0 : getMetricsChain().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", strategyId=").append(strategyId);
        sb.append(", strategyName=").append(strategyName);
        sb.append(", strategyDesc=").append(strategyDesc);
        sb.append(", strategyType=").append(strategyType);
        sb.append(", loadChain=").append(loadChain);
        sb.append(", alertType=").append(alertType);
        sb.append(", checkerChain=").append(checkerChain);
        sb.append(", metricsChain=").append(metricsChain);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}